package WorkTask2;

public class Total {
    public static void main(String[] args) {
        //编程统计字符串"ABCD123!@#$%ab"中大写字母、小写字母、数字、其它字符的个数并打印出来。
        String s = "ABCD123!@#$%ab";
        char[] a = s.toCharArray();
        int upperCase = 0;//统计大写字母的个数！
        int lowCase = 0;//统计小写字母！
        int num = 0;//统计数字个数
        for (int i = 0; i < a.length; i++) {
            if (Character.isUpperCase(a[i])){
                System.out.println("下标" + i + "的字符为大写字母");
                upperCase++;
            }
            if (Character.isLowerCase(a[i])){
                System.out.println("下标" + i + "的字符为小写字母");
                lowCase++;
            }
            if (Character.isDigit(a[i])){
                System.out.println("下标" + i + "的字符为数字");
                num++;
            }

        }

        System.out.println("大写字母个数为" + upperCase);
        System.out.println("小写字母个数为" + lowCase);
        System.out.println("数字个数为" + num);
        System.out.println("其他字符个数为" + (14 -(upperCase + lowCase +num)));

    }
}
